package com.xxx.video.main.presenters;

import android.content.Context;

import androidx.annotation.NonNull;

import com.xxx.video.commen.presenters.BasePresenter;
import com.xxx.video.commen.utils.ResponseUtils;
import com.xxx.video.main.beans.RankListBean;
import com.xxx.video.network.listeners.CommonResponseListener;
import com.xxx.video.network.utils.NetWorkUtils;

public class RankListPresenter extends BasePresenter<IRankListView> {
    public RankListPresenter(@NonNull Context context, IRankListView baseView) {
        super(context, baseView);
    }

    /**
     * get rank list
     *
     * @param page page
     * @param type type
     */
    public void getRankList(int page, String type) {
        NetWorkUtils.getInstance().getRankList(page, type, new CommonResponseListener<RankListBean>() {

            @Override
            public void onSuccess(RankListBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().initData2View(successOb);
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {
                if (getBaseView() != null) {
                    getBaseView().showRootLayoutStatus(3);
                }
            }
        });
    }
}
